草庐IT

swift - 3D Touch 和 UITableViewCell

全部标签

ios - uitableViewCell 的索引路径

这个问题在这里已经有了答案:GettingrowofUITableViewcellonbuttonpress(10个答案)关闭9年前。我有一个自定义方法来检测对单元格图像的点击。我还想找到图像相关单元格的索引路径,并在函数中使用它。这是我正在使用的:CellforRowAtIndexPath:UITapGestureRecognizer*tapped=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(cellImageTapped:)];tapped.numberOfTapsRequired=1;[cel

ios - 为 UITableViewCell 加载自定义 XIB

我正在尝试为UITableViewCell使用自定义XIB文件,但无论我做什么,表格单元格始终为空-我的XIB根本没有加载。没有任何错误。这是我的做法:创建一个空应用程序,添加Storyboard、表格ViewController,添加新的UITableViewController,将其与表格Hook并设置一些示例项目。创建一个Controller作为UITableViewCell的子类+选中生成XIB的选项。创建三个示例标签并将它们添加为IBOutlets。加载XIB文件并尝试将其设置为单元格。代码:-(void)viewDidLoad{[superviewDidLoad];self

ios - 如何在 xcode 7 的 Swift 2.0 中使用 NSRegularExpression

//错误在这里letregex=NSRegularExpression(pattern:"()",options:nil,error:nil)//错误是:***cannotfindaninitializerfortypensregularexpressionthatacceptanargumentoftype(pattern:string,ption:nil,error:nil) 最佳答案 Swift2.0中的语法有2处变化:(1)您将调用包装在try...catchblock中,而不是提供error范围;(2)options应该是

ios - swift 3.0 中的 Sha 256 加密语法错误

funcSHA256()->String{letdata=self.data(using:String.Encoding.utf8)letres=NSMutableData(length:Int(CC_SHA256_DIGEST_LENGTH))CC_SHA256((data!asNSData).bytes,CC_LONG(data!.count),UnsafeMutablePointer(res!.mutableBytes))lethashedString="\(res!)".replacingOccurrences(of:"",with:"").replacingOccurrenc

Swift 变量、常量和数据类型

欢迎您阅读 MasteringSwift 基础教程,本文我们将介绍Swift中的变量、常量和数据类型。如果你尚未安装Xcode和配置Swift开发环境,请您先阅读这篇文章。接下来,我们启动Xcode,然后选择"File">"New">"Playground"。创建一个新的Playground并命名为"Variables"。声明和使用变量在Swift使用 var 关键字定义变量。变量值可以在其生命周期中被改变。而在TypeScript中,是使用 var 或 let 关键字定义变量。Swift代码varname="Kakuqo"name="Semlinker"TypeScript代码letname

ios - UITableViewCell 滚动后数据消失

我在arc项目中有一个tableView。当我滚动它一秒钟时,所有数据都会隐藏或消失。我正在通过Strong属性从另一个Controller传递数据。CTableViewController*cTableVc=[[CTableViewControlleralloc]initWithNibName:@"CTableViewController"bundle:nil];cTableVc.cArray=[[NSArrayalloc]initWithArray:[MyVCpathForAllCardsInDocumentDiretory]];cTableVc.view.frame=CGRect

ios - Swift3 圆了 UIView 的两个角

我知道这个问题已经被问过很多次了,他们的解决方案也可用,但对我来说没有任何用处。我正在使用Swift3并且我想为此目的将UIView的任意两侧四舍五入我找到了以下解决方案Createarectanglewithjusttworoundedcornersinswift?下面是我上述解决方案的代码片段extensionUIView{/**Roundsthegivensetofcornerstothespecifiedradius-parametercorners:Cornerstoround-parameterradius:Radiustoroundto*/funcround(corner

ios - swift : Is there a way to test if object cast as AnyObject conforms to Equatable?

我有一个具有键控属性的对象:funcvalue(key:String)->AnyObject?funcsetValue(value:AnyObject?,key:String)我想检查从具有来自两个不同对象的相同键的value函数返回的值是否Equatable。Swift提示是因为Equatable有一个Self引用并且只能在泛型中使用。有没有一种方法可以检查从value函数返回的AnyObject对象是否符合Equatable? 最佳答案 由于Swift2的变化,我正在编辑我的答案要检查协议(protocol)一致性,只需使用is

ios - Facebook SDK FBSession 代码不适用于 Swift

尝试在Swift中实现这个ObjectiveC代码://Wheneverapersonopenstheapp,checkforacachedsessionif(FBSession.activeSession.state==FBSessionStateCreatedTokenLoaded){//Ifthere'sone,justopenthesessionsilently,withoutshowingtheusertheloginUI[FBSessionopenActiveSessionWithReadPermissions:@[@"public_profile"]allowLoginU

ios - KIF 无法点击 UITableViewCell 中的 UIButton 如果它是它的 UITableView 的唯一一个

我在自动点击嵌入在UITableViewCell中的UIButton时遇到问题,如果该单元格是表格的唯一单元格。这是在使用KIF的UI自动化的上下文中。这是我的相关电话:[testertapViewWithAccessibilityLabel:@"LABEL"traits:UIAccessibilityTraitButton];//traitonlyspecifiedfor2ndcasebelow这是我观察到的:如果我将可访问性标签放在UITableViewCell上,KIF的KIFUITestActor-waitForAccessibilityElement:view:withLab